package com.mfcxy.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;


public class AdminLogInterceptor extends HandlerInterceptorAdapter{
private static Logger log = Logger.getLogger(AdminLoginInterceptor.class);
	
	/**
	 * 渲染视图之后被调用
	 */
	@Override
	public void afterCompletion(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, Exception arg3)
			throws Exception {
		// TODO Auto-generated method stub
	}
	
	/**
	 * 调用目标方法之后，但渲染视图之前被调用
	 */
	@Override
	public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, ModelAndView arg3)
			throws Exception {
		// TODO Auto-generated method stub
		
	}
	
	/**
	 * 该方法在目标方法之前被调用
	 * 若返回值为true，则继续调用后续操作
	 * 若返回值为false，则不会调用
	 */
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object arg2) throws Exception {
		log.info(request.getRequestURL());
		log.info("该方法在目标方法之前被调用:log");
		return true;
	}
}
